package com.kws.system.controller.Payment;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kws.common.core.domain.R;
import com.kws.system.domain.payment.info.QueryCommodityPayOrderInfo;
import com.kws.system.domain.payment.rq.QueryCommodityPayOrderRq;
import com.kws.system.service.payment.OrderManagementService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <b>CommodityPayOrderController</b>
 *
 * @description: CommodityPayOrderController <br>
 * @date: 2024/11/22 13:11 <br>
 * @author: lhm <br>
 * @version: 1.0 <br>
 */

@Api(tags = "商品支付订单")
@RestController
public class CommodityPayOrderController {
    private static final Logger logger = LoggerFactory.getLogger(CommodityPayOrderController.class);

    @Autowired
    private OrderManagementService orderManagementService;

    @ApiOperation("分页查询商品支付订单列表")
    @PostMapping("/query/commodityPayOrder/page")
    public R<Page<QueryCommodityPayOrderInfo>> queryCommodityPayOrderPage(@RequestBody QueryCommodityPayOrderRq rq){
        Page<QueryCommodityPayOrderInfo> pageInfo = orderManagementService.queryCommodityPayOrderPage(rq);
        return R.ok(pageInfo);
    }

    @ApiOperation("根据ID查询商品支付订单详情")
    @GetMapping("/query/commodityPayOrder/byId")
    public R<QueryCommodityPayOrderInfo> queryCommodityPayOrderById(@RequestParam Long id){
        QueryCommodityPayOrderInfo info = orderManagementService.queryCommodityPayOrderById(id);
        return R.ok(info);
    }

    @ApiOperation("根据ID进行退款处理")
    @GetMapping("/refund/order")
    public R refundOrder(@RequestParam Long id){
        boolean status = orderManagementService.refundOrder(id);
        return R.ok(status);
    }
}
